/**
 * 
 */
package dms.presentation.form.sys;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import dms.dto.DormSupervisorDTO;

/**
 * @author lrz
 *
 */
public class DormSupervisorUpdateForm extends DormSupervisorDTO {

	/* (non-Javadoc)
	 * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
	 */
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();

		if (building == null) {
			errors.add("errors", new ActionMessage("缺少楼栋", false));
		}
		
		if (oldPassword != null && oldPassword.length() > 0) {
			if (password == null || password.length() == 0) {
				errors.add("缺少新密码", new ActionMessage("缺少新密码", false));
			}
		}
		
		if (password != null && password.length() > 0) {
			if (oldPassword == null || oldPassword.length() == 0) {
				errors.add("缺少原密码", new ActionMessage("缺少原密码", false));
			}
		}
		return errors;
	}

}
